<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <!-- <meta charset="gb2312"> -->
    
    <meta name="author" content="流星的泪痕 QQ:61955365">

    <meta name="Keywords" content="">
    <meta name="description" content="">
    
    <!-- 启用360浏览器的极速模式(webkit)-->
        <meta name="renderer" content="webkit">          
        <!-- 避免IE使用兼容模式 -->
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
    
    <!-- mobile -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
    
    <link rel="shortcut icon" href="favicon.ico" type="images/x-icon" />
    <link rel="bookmark" href="favicon.ico" />
    
    <title>金塔珠宝</title>
    <!--[if lt IE 9 ]>
            <script src="js/hack/html5shiv.js"></script>
        <![endif]-->
<!--        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>-->
        
<!--        <script src="http://192.168.1.106:81/con/assets/js/f5.js"></script>-->

    <link rel="stylesheet" href="../Public/css/base.css">
    <link rel="stylesheet" href="../Public/css/common.css">
    <link rel="stylesheet" href="../Public/css/page.css">
    <link rel="stylesheet" href="../Public/css/font.css">
        <link rel="stylesheet" href="../Public/css/responsive.css">
        
    <style>
.list_wrap img{width: 100%}
.icon_heart2{color: #ccc}
.icon_heart{color: #ccc}
.favour{
  width: 35px;
  height: 35px;
  display: block;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    position: absolute;
    right: 4px;
    top: -18px;
        text-align: center;
   
}
.favour i{   
    font-size: 18px;
    margin-top: 10px;
    opacity: 0.6;
    display: inline-block}

    </style> 
  </head>
  <body>
        <!-- nav [[ -->
<include file="Common:header"/>
    <!-- nav ]] -->

    <!-- header [[ -->
  <!--       <header class="header">
            <div class="title">
                <div class="bg">
                    <span class="icon"></span>
                    <span class="txt">珠宝详细</span>
                </div>
            </div>
        </header> -->
    <!-- header ]] -->
        
        <!-- content [[ -->
        <div class="content mod_product_detail">
            <div class="info">
                <div class="img_warp">
                    <img src="Uploads/{$shangpind.img}" alt="" class="img">
                </div>
                <div class="txt_wrap" style="">
                    <h1 class="title">{$shangpind.name}</h1>
                    <notempty name="shangpind.chengse">
                     <p class="txt ">
                        <span class="txt_title">材质</span>
                        {$shangpind.chengse}
                    </p>
                    </notempty>
                    
                     <notempty name="shangpind.guige">
                    <p class="txt ">
                        <span class="txt_title">规格</span>
                        {$shangpind.guige}
                    </p>
                    </notempty>
                    <notempty name="shangpind.jinz">
                    <p class="txt integral">
                        <span class="txt_title">重量</span>
                        <select  style="width: 68%;outline: none;border: 1px solid #cccccc"  class="zhongliang">
                        <volist name="ljj" id="vo">  
                        <option  value="{$vo.huxing}">{$vo.huxing}</option>
                        </volist>
                        </select>
                    </p>
                       </notempty>
                        <notempty name="shangpind.yanse">
                    <p class="txt ">
                        <span class="txt_title">颜色</span>
                        <select  style="width: 68%;outline: none;border: 1px solid #cccccc" class="yanse">
                        <volist name="zlist" id="vo"> 
                        <option  value="{$vo.yanse}">{$vo.yanse}</option>
                        </volist>
                        </select>
                    </p>
                      </notempty>
                        <p class="txt ">
                        <span class="txt_title">数量</span>
                    <input style="width: 20%;outline: none;border: 1px solid #cccccc;text-align: center;    -webkit-border-radius: 0px;background: #cccccc;border-radius:0px;-webkit-appearance:button" type="button" value="-" >
                     <input style="width: 20%; text-align: center;outline: none;font-size:14px;border: 1px solid #cccccc;border-radius:0px;-webkit-border-radius: 0px; background: #fff;" class="shuliang" type='number' pattern="[0-9]*" value="1" >
                     <input style="width: 20%;outline: none;border: 1px solid #cccccc;text-align: center;    -webkit-border-radius: 0;background: #cccccc;border-radius:0px;-webkit-appearance:button"  type="button" value="+" >
                         </p>
                       <!--   <div class="favour" onclick="shoucang(this);"  data-id='{$shangpind.id}'>
                         <i class="icon <if condition="in_array($shangpind['id'],$shangpin)">icon_heart<else/>icon_heart2</if>"></i>
                         </div> -->
                </div>
                <div class="btn_wrap clear">
                        <a href="javascript:;" onclick="xiadan();" class="mod_btn">立即下单</a>
                        <a href="javascript:;" onclick="gw();" class="mod_btn">加入购物车</a>
                </div>
                                <input type="hidden" name="goodsid" id="goodsid" value="{$shangpind.id}">    
                    <input class="session" type="hidden" value="{$_SESSION['userr']}">
            </div>
            <div class="detail">
                <h2 class="sub_title">产品详细</h2>
                
                <div class="list_wrap">
                    {$shangpind.intro}

                </div>
                
                
                
                
            </div>
        </div>
        <!-- content ]] -->
        
        <!-- footer [[ -->
        <include file="Common:footer"/>
        <script type="text/javascript" src="../Public/layer/layer.js"></script>
    
<script>

$(function(){

  $('input[value="-"]').click(function(){
   var num=parseInt($('input[type="number"]').val());
   if (num>1) {
      $('input[type="number"]').val(num-1);

   }

  })

$('input[value="+"]').click(function(){
       var num=parseInt($('input[type="number"]').val());
        if (num>=1) {
      $('input[type="number"]').val(num+1);
       }

})
// $('input[type="text"]').click(function(){
//     $('input[type="text"]').val('1');
// })
})
// 限制e输入
// $('input[type=number]').keypress(function(e) {
// 　　if (!String.fromCharCode(e.keyCode).match(/[0-9\.]/)) {
// 　　　　return false;
// 　　}
// });
function xiadan(){
    if ($('.session').val()=='') {

        layer.msg('请登录后下单',{time: 1000},function(){

            location.href='{:U("User/login")}';
        });
       }else{
    var id=$('#goodsid').val();
    var zhongliang=$('.zhongliang').val();
    var yanse=$('.yanse').val();
    var shuliang=$('.shuliang').val();

         $.ajax({
      url:'{:U("User/xiadan")}',
      data:{
         'spid':id,
         'zhongliang':zhongliang,
         'yanse':yanse,
         'shuliang':shuliang,
        },
        type:'post',
        dataType:'json',
        success:function(data){
  if (data==1) {
       location.href='{:U("Orders/index",array("id"=>$shangpind["id"]))}';}
        }

    });


       }
  

}
function gw(){

       if ($('.session').val()=='') {

         layer.msg('请登录后购买',{time: 1000},function(){

            location.href='{:U("User/login")}';
        });
       }else{
         var id=$('#goodsid').val();
    var zhongliang=$('.zhongliang').val();
    var yanse=$('.yanse').val();
    var shuliang=$('.shuliang').val();


    $.ajax({
         url:'{:U("User/gw")}',
         type:'post',
         data:{
             'id':id,
              'zhongliang':zhongliang,
         'yanse':yanse,
         'shuliang':shuliang,
         },
         success:function(data){
           
            if (data==1) {

                    layer.msg('加入购物车成功',{time:1000}
                      ,function(){
                      location.replace(location.href);


                    });
                    



                 

            }else if(data==2){
           layer.msg('已加入购物车',{time:1000});
            }else{

                layer.msg('添加购物车失败',{time:1000});
            }


         }


    })
}


}

function shoucang(obj){
    if ($('.session').val()=='') {
       layer.msg('请登录后收藏',{time: 1000},function(){

            location.href='{:U("User/login")}';
        });
  }else{




    if($(obj).find('i').hasClass("icon_heart"))
    {
     $(obj).find('i').removeClass("icon_heart").addClass("icon_heart2");
        var id= $('.favour').attr('data-id');
            $.ajax({
                  url:'{:U("User/shoucang1")}',
                  type:'post',
                  data:{
                      shangpin:id
                  },
                  success:function(data){
                  if(data==1){

                    layer.msg('取消收藏',{time: 1000,});
                  }


                  }

            })


    }
    else
    {
      $(obj).find('i').removeClass("icon_heart2").addClass("icon_heart");
            var id= $('.favour').attr('data-id');
            $.ajax({
                  url:'{:U("User/shoucang1")}',
                  type:'post',
                  data:{
                      shangpin:id
                  },
                  success:function(data){
                  if(data==1){

                    layer.msg('收藏成功',{time: 1000,});
                  }


                  }



            })
    }}
}
</script>
  </body>
</html>